473,425 Members | 1,670 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,425 software developers and data experts.

Passing Quotes in a URL Call

Using ASP 3.0

I want to dynamically build a call to another asp page and include some
parameters as part of the call. The basic format of the call is something
like::

"<a href='mypage.asp?id=" & theid & "&location='" & thelocation &
"'>GO</a>"

where there is a single quote followed by a double quote following the
...location=... and vica-versa after the variable

My problem is that the variable thelocation can include a single quote or a
double quote. I tried Server.URLEncode and that didn't work. I got a string
that ended up causing a Page Not Found (it encoded the dot in the page name
and that didn't work)

How can I encode the data so that quotes will be accepted in this type of
call?

Wayne
Jul 19 '05 #1
4 14892
Did you decode the URL at the other end when you encoded
it?

Try the following code before you reconstruct the call to
the page..

<%
Function myURLDecode(strString)
strString = Replace(strString, "%2F", "/")
strString = Replace(strString, "%7C", "|")
strString = Replace(strString, "%3F", "?")
strString = Replace(strString, "%21", "!")
strString = Replace(strString, "%40", "@")
strString = Replace(strString, "%5C", "\")
strString = Replace(strString, "%23", "#")
strString = Replace(strString, "%24", "$")
strString = Replace(strString, "%5E", "^")
strString = Replace(strString, "%26", "&")
strString = Replace(strString, "%25", "%")
strString = Replace(strString, "%2A", "*")
strString = Replace(strString, "%28", "(")
strString = Replace(strString, "%29", ")")
strString = Replace(strString, "%7D", "}")
strString = Replace(strString, "%3A", ":")
strString = Replace(strString, "%2C", ",")
strString = Replace(strString, "%7B", "{")
strString = Replace(strString, "%2B", "+")
strString = Replace(strString, "%2E", ".")
strString = Replace(strString, "%2D", "-")
strString = Replace(strString, "%7E", "~")
strString = Replace(strString, "%2D", "-")
strString = Replace(strString, "%5B", "[")
strString = Replace(strString, "%5F", "_")
strString = Replace(strString, "%5D", "]")
strString = Replace(strString, "%60", "`")
strString = Replace(strString, "%3D", "=")
strString = Replace(strString, "%27", "'")
strString = Replace(strString, "+", " ")
strString = Replace(strString, "%22", Chr(34))
myURLDecode = strString
End Function
%>
Jul 19 '05 #2

"Wayne Wengert" <wa***************@wengert.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Using ASP 3.0

"<a href='mypage.asp?id=" & theid & "&location='" & thelocation &
"'>GO</a>"

where there is a single quote followed by a double quote following the
..location=... and vica-versa after the variable

My problem is that the variable thelocation can include a single quote or a double quote. I tried Server.URLEncode and that didn't work. I got a string that ended up causing a Page Not Found (it encoded the dot in the page name and that didn't work)


Sounds like you were possibly trying Server.URLEncode in the wrong place...

I would say this should work :

Response.write "<a href='mypage.asp?id=" & Server.URLEncode(theid) &
"&location='" & Server.URLEnCode(thelocation) & "'>GO</a>"
Jul 19 '05 #3
Thanks Dan. You were right. I used the URLEncode on the whole call instead
of just the pieces that needed it.

Wayne

"Dan Boylett" <ms*******@crossdata.co.uk> wrote in message
news:ek**************@TK2MSFTNGP10.phx.gbl...

"Wayne Wengert" <wa***************@wengert.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Using ASP 3.0

"<a href='mypage.asp?id=" & theid & "&location='" & thelocation &
"'>GO</a>"

where there is a single quote followed by a double quote following the
..location=... and vica-versa after the variable

My problem is that the variable thelocation can include a single quote
or a
double quote. I tried Server.URLEncode and that didn't work. I got a string
that ended up causing a Page Not Found (it encoded the dot in the page

name
and that didn't work)


Sounds like you were possibly trying Server.URLEncode in the wrong

place...
I would say this should work :

Response.write "<a href='mypage.asp?id=" & Server.URLEncode(theid) &
"&location='" & Server.URLEnCode(thelocation) & "'>GO</a>"

Jul 19 '05 #4
Very Handy function. Thanks

Wayne

"Kevin" <an*******@discussions.microsoft.com> wrote in message
news:03****************************@phx.gbl...
Did you decode the URL at the other end when you encoded
it?

Try the following code before you reconstruct the call to
the page..

<%
Function myURLDecode(strString)
strString = Replace(strString, "%2F", "/")
strString = Replace(strString, "%7C", "|")
strString = Replace(strString, "%3F", "?")
strString = Replace(strString, "%21", "!")
strString = Replace(strString, "%40", "@")
strString = Replace(strString, "%5C", "\")
strString = Replace(strString, "%23", "#")
strString = Replace(strString, "%24", "$")
strString = Replace(strString, "%5E", "^")
strString = Replace(strString, "%26", "&")
strString = Replace(strString, "%25", "%")
strString = Replace(strString, "%2A", "*")
strString = Replace(strString, "%28", "(")
strString = Replace(strString, "%29", ")")
strString = Replace(strString, "%7D", "}")
strString = Replace(strString, "%3A", ":")
strString = Replace(strString, "%2C", ",")
strString = Replace(strString, "%7B", "{")
strString = Replace(strString, "%2B", "+")
strString = Replace(strString, "%2E", ".")
strString = Replace(strString, "%2D", "-")
strString = Replace(strString, "%7E", "~")
strString = Replace(strString, "%2D", "-")
strString = Replace(strString, "%5B", "[")
strString = Replace(strString, "%5F", "_")
strString = Replace(strString, "%5D", "]")
strString = Replace(strString, "%60", "`")
strString = Replace(strString, "%3D", "=")
strString = Replace(strString, "%27", "'")
strString = Replace(strString, "+", " ")
strString = Replace(strString, "%22", Chr(34))
myURLDecode = strString
End Function
%>

Jul 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Kevin Lyons | last post by:
Hello, I am trying to get my select options (courses) passed correctly from the following URL: http://www.dslextreme.com/users/kevinlyons/selectBoxes.html I am having difficulty getting the...
58
by: jr | last post by:
Sorry for this very dumb question, but I've clearly got a long way to go! Can someone please help me pass an array into a function. Here's a starting point. void TheMainFunc() { // Body of...
22
by: Arne | last post by:
How do I pass a dataset to a webservices? I need to submit a shoppingcart from a pocket PC to a webservice. What is the right datatype? II have tried dataset as a datatype, but I can't get it to...
3
by: Brian | last post by:
Hope someone can help ..... Have a function which creates a HTML HREF function fLink(aText) { return '<a href=javascript:DoLinkSearch("'+aText+'")>'+aText+'</a>'; } If the parameter value is...
1
by: I.am.the.Buddha | last post by:
I am still learning asp and sql. I am having trouble with passing a variable to within an sql statement. I am sure it is something simple like misuse of quotes. Since it may help if i say what i...
5
by: nephish | last post by:
hey there, can anyone tell me if this is legal php/mysql ? i am trying to write a simple function to get a single stat from a single table. eg.. $field = 'phone_number'; $customer = 'fred';
0
by: kencana | last post by:
hi All, I got problem in passing data (more than one) from soap client to the soap server. but if i only passing one data at a time, it works successfully.. The following is the error message i...
6
by: rynato | last post by:
I am embarrassed that I cannot figure this out, as it seems fairly simple. I found a JS function I'd like to use, which animates a layer so that it moves across the screen. The problem is the...
5
by: moni | last post by:
Hi.. I am trying to use javascript for google maps display. If I call the javascript function from my aspx file I use: <input type="text" id="addresstext" value="Huntington Avenue,...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.